<#include "/common/include.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="地区列表"/>
<@search fromId="dept-form">
    <div class="select-list">
        <ul>
            <li>
                地区名称：<input type="text" name="name"/>
            </li>
            <li>
                类型：
                <select name="type">
                    <option value=""><@ctx.i18n text = "所有"/></option>
                    <#list dict.getType('sys_dept_line')>
                        <#items as d>
                            <#if d.status =='0' >
                                <option value="${d.dictValue}" text="${d.dictLabel}">${d.dictLabel}</option>
                            </#if>
                        </#items>
                    </#list>
                </select>
            </li>
            <li>
                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;<@ctx.i18n text = "查询"/></a>
                <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "重置"/></a>
            </li>
        </ul>
    </div>
</@search>
<@table tableId="bootstrap-tree-table">
    <@shiro.hasPermission name="sys:dept:add">
        <a class="btn btn-success" onclick="opt.operate.add(1)"><i class="fa fa-plus"></i>&nbsp;<@ctx.i18n text = "新增"/></a>
    </@shiro.hasPermission>
    <@shiro.hasPermission name="sys:dept:edit">
        <a class="btn btn-primary" onclick="opt.operate.edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;<@ctx.i18n text = "修改"/></a>
    </@shiro.hasPermission>
    <a class="btn btn-info" id="expandAllBtn">
        <i class="fa fa-exchange"></i> 展开/折叠
    </a>
</@table>
<@footer>
<script>
    var addFlag = "${permission.hasPermi('sys:dept:add')}";
    var editFlag = "${permission.hasPermi('sys:dept:edit')}";
    var deleFlag = "${permission.hasPermi('sys:dept:del')}";
    var visible = ${permission.isPermitteds("sys:dept:edit,sys:dept:del")?string('true', 'false')};
    var datas = ${dict.getDictListJson('sys_dept_line')};
    var prefix = baseURL + "sys/dept";

    $(function() {
        var options = {
            code: "deptId",
            parentCode: "parentId",
            uniqueId: "deptId",
            url: prefix + "/list",
            expandAll:false,
            addUrl: prefix + "/add/{id}",
            editUrl: prefix + "/edit/{id}",
            delUrl: prefix + "/del/{id}",
            modalName: "地区",
            columns: [
                {field: 'selectItem', radio: true},
                {field: 'name', title: "<@ctx.i18n text = "地区名称"/>", align: "left"},
                {field: 'orderNum', title: "<@ctx.i18n text = "排序"/>", align: "left"},
                {field: 'parentName', title: "<@ctx.i18n text = "上级"/>"},
                {field: 'type', title: "<@ctx.i18n text = "类型"/>", align: "left", formatter: function(value, item, index) {
                        return $.table.selectDictLabel(datas, item.type);}
                },
                {field: 'createTime', title: "<@ctx.i18n text = "创建时间"/>", align: "left"},
                {title: "<@ctx.i18n text = "操作"/>", align: 'left', visible:visible,formatter: function(value, row, index) {
                        if (row.type == 0) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="opt.operate.edit(\'' + row.deptId + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "编辑"/></a> ');
                            actions.push('<a class="btn btn-info  btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="opt.operate.add(\'' + row.deptId + '\')"><i class="fa fa-plus"></i><@ctx.i18n text = "新增"/></a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + deleFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.deptId + '\')"><i class="fa fa-trash"></i><@ctx.i18n text = "删除"/></a>');
                            return actions.join('');
                        } else {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="opt.operate.edit(\'' + row.deptId + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "编辑"/></a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + deleFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.deptId + '\')"><i class="fa fa-trash"></i><@ctx.i18n text = "删除"/></a>');
                            return actions.join('');
                        }}
                }]
        };
        $.treeTable.init(options);
    });
</script>
</@footer>
</@pageTheme>